cmake_minimum_required(VERSION 3.26.0)
project(ACIMViewer_Lite)

if (MSVC)
    add_compile_options($<$<CXX_COMPILER_ID:MSVC>:/utf-8>)
endif ()

# find_package(Qt5 COMPONENTS Core Gui Widgets OpenGL REQUIRED)

# find_package(Qt5 COMPONENTS Core Gui Widgets OpenGL OpenGLWidgets REQUIRED)

find_package(Qt6 COMPONENTS Core Gui Widgets OpenGL OpenGLWidgets REQUIRED)
#find_package(QT NAMES Qt5 COMPONENTS Core Gui Widgets OpenGL REQUIRED)
#find_package(QT NAMES Qt6 Qt5 COMPONENTS Core REQUIRED)
#find_package(Qt${QT_VERSION_MAJOR} 5.8 COMPONENTS Core Gui Widgets OpenGL REQUIRED)

message(STATUS "current Qt version is Qt${QT_VERSION_MAJOR}.${QT_VERSION_MINOR}.${QT_VERSION_PATCH}")

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_AUTOUIC ON)

include_directories(${CMAKE_SOURCE_DIR}/3rdlibs/include)
include_directories(${CMAKE_SOURCE_DIR}/LibCIMModel)
include_directories(${CMAKE_SOURCE_DIR}/3rdlibs)

# set(G_TmpQtHomePath E:/dev/gdmplab8/gmdp/3rdparty/qt/5.6.3/msvc2015_64)
set(G_TmpQtHomePath D:/Qt/6.7.1/msvc2019_64)

include_directories(${G_TmpQtHomePath}/include)
include_directories(${G_TmpQtHomePath}/include/QtCore)
include_directories(${G_TmpQtHomePath}/include/QtOpenGL)
include_directories(${G_TmpQtHomePath}/include/QtWidgets)
include_directories(${G_TmpQtHomePath}/include/QtOpenGLWidgets)

# include_directories(E:/dev/gdmplab8/gmdp/3rdparty/qt/5.6.3/msvc2015_64/include)
# include_directories(E:/dev/gdmplab8/gmdp/3rdparty/qt/5.6.3/msvc2015_64/include/QtOpenGL)
# include_directories(E:/dev/gdmplab8/gmdp/3rdparty/qt/5.6.3/msvc2015_64/include/QtOpenGLWidgets)

# include_directories(D:/Qt/6.7.1/msvc2019_64/include)
# include_directories(D:/Qt/6.7.1/msvc2019_64/include/QtOpenGL)
# include_directories(D:/Qt/6.7.1/msvc2019_64/include/QtOpenGLWidgets)

link_directories(${CMAKE_SOURCE_DIR}/out/build/OpenCIM/LibCIMModel)

set(G_TmpOsgQtInstallPath D:/osgQt/Install)

set(G_TmpLibPaths
			debug ${CMAKE_SOURCE_DIR}/3rdlibs/lib/debug ${G_TmpOsgQtInstallPath}/lib
			optimized ${CMAKE_SOURCE_DIR}/3rdlibs/lib/release)
			
link_directories(${G_TmpLibPaths})

#[[
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
    message("Debug mode is enabled.")
    link_directories(${CMAKE_SOURCE_DIR}/3rdlibs/lib/debug)
else ()
    message("Release mode is enabled.")
    link_directories(${CMAKE_SOURCE_DIR}/3rdlibs/lib/release)
endif ()
]]

add_executable(ACIMViewer_Lite
        main.cpp
        Tool/OSGBTool.cpp
        Tool/OSGBTool.hpp
        ViewModel/MainWindowViewModel.cpp
        ViewModel/MainWindowViewModel.hpp
        View/ModelWidget.cpp
        View/ModelWidget.hpp
        View/MainWindow.cpp
        View/MainWindow.hpp
)

# set(G_TmpQtLibraries Qt5::Core Qt5::Gui Qt5::Widgets Qt5::OpenGL) # Qt5::OpenGLWidgets)
set(G_TmpQtLibraries Qt6::Core Qt6::Gui Qt6::Widgets Qt6::OpenGL Qt6::OpenGLWidgets)

set(G_TmpLibraries
			debug ${G_TmpQtLibraries} osgd osgQOpenGLd osgEarthd osgViewerd osgGAd osgDBd OpenThreadsd LibCIMModel_d proj_4_9_d
			optimized ${G_TmpQtLibraries} osg osgQOpenGL osgEarth osgViewer osgGA osgDB OpenThreads LibCIMModel_r proj_4_9)

target_link_libraries(ACIMViewer_Lite ${G_TmpLibraries})			

#[[
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
    target_link_libraries(ACIMViewer_Lite
            Qt5::Core
            Qt5::Gui
            Qt5::Widgets
            Qt5::OpenGL
            Qt5::OpenGLWidgets
            osgd
            osgQOpenGLd
            osgEarthd
            osgViewerd
            osgGAd
            osgDBd
            OpenThreadsd
            LibCIMModel_d
            proj_4_9_d
    )
else ()
    target_link_libraries(ACIMViewer_Lite
            Qt6::Core
            Qt6::Gui
            Qt6::Widgets
            Qt6::OpenGL
            Qt6::OpenGLWidgets
            osg
            osgQOpenGL
            osgEarth
            osgViewer
            osgGA
            osgDB
            OpenThreads
            LibCIMModel_r
            proj_4_9
    )
endif ()
]]